package com.xunhang.config;

import com.xunhang.utils.JWTInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@AllArgsConstructor
public class MvcConfig implements WebMvcConfigurer {
    private final StringRedisTemplate stringRedisTemplate;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new LoginInterceptor())
//                .excludePathPatterns(
//                        "shop/**",
//                        "voucher/**",
//                        "shop-type/**",
//                        "upload/**",
//                        "blog/hot",
//                        "user/login",
//                        "user/**",
//                        "user/hot"
//                ).order(1);
        registry.addInterceptor(new JWTInterceptor(stringRedisTemplate)).addPathPatterns("/**").order(0);
    }
}
